﻿Imports CupsApp.Data

Public Class MockRepository(Of T As Class)
    Implements IRepository(Of T)

    Private inMemoryTables As Dictionary(Of Type, List(Of T)) = New Dictionary(Of Type, List(Of T))()

    Public ReadOnly Property Table() As List(Of T)
        Get
            Return inMemoryTables(GetType(T))
        End Get
       
    End Property



    Protected Sub AddTable()
        Dim table As List(Of T) = New List(Of T)
        inMemoryTables.Add(GetType(T), Table)
    End Sub


    Public Function Add(ByVal entity As T) As T Implements Data.IRepository(Of T).Add
        Table.Add(entity)
        Return entity
    End Function

    Public Sub Attach(ByVal current As T) Implements Data.IRepository(Of T).Attach

    End Sub

    Public Sub Attach(ByVal current As T, ByVal original As T) Implements Data.IRepository(Of T).Attach

    End Sub

    Public Function Query() As System.Linq.IQueryable(Of T) Implements Data.IRepository(Of T).Query
        Return Table.AsQueryable()
    End Function

    Public Sub Remove(ByVal entity As T) Implements Data.IRepository(Of T).Remove
        Table.Remove(entity)
    End Sub

    Public Sub SubmitChanges() Implements Data.IRepository(Of T).SubmitChanges

    End Sub
End Class
